package cn.zhouchao.basic.dto;

import cn.zhouchao.basic.util.MD5Utils;
import cn.zhouchao.basic.util.StrUtils;
import cn.zhouchao.org.domain.Employee;
import cn.zhouchao.user.domain.User;
import lombok.Data;
import java.util.Date;

@Data
public class VerifyCodeDto {

    private String phone;//手机号

    private String phoneImageCodeValue;//手机图形验证码

    private String phoneImageCodeKey;//手机图形验证码Key--uuid

    private String phoneCode;// 手机号验证码

    private String password;//一次密码

    private String passwordRepeat;//二次密码

    private String type;//绑定binder或者注册register

    public User getUser(){
        String salt = StrUtils.getComplexRandomString(32);
        String pw = MD5Utils.encrypByMd5(salt + this.password);//盐值加密
        return User
                .builder()
                .username(this.phone)
                .phone(this.phone)
                .salt(salt)
                .password(pw)
                .state(1)
                .createtime(new Date())
                .build();
    }
    public Employee getEmployee(){
        String salt = StrUtils.getComplexRandomString(32);
        String pw = MD5Utils.encrypByMd5(salt + this.password);//盐值加密
        return Employee
                .builder()
                .username(this.phone)
                .phone(this.phone)
                .salt(salt)
                .password(pw)
                .state(1)
                .build();
    }

}
